exports.organizationCourseCollect = function (req, res) {

    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    var courseData = [];

    var skip  =  restfulParams.skip == undefined  ? 0 : restfulParams.skip;
    var limit =  restfulParams.limit == undefined ? config.publicConfig.LIMIT : restfulParams.limit;


    //任务流创建
    async.waterfall([
            
        //1.用户收藏机构
        function (cb) {
            R.SEND_HTTP(
                req,
                {
                    url: CORE_APIConfig.coreAPI.organizationCourseCollect + "/uc_uid/" + restfulParams.u_id  + "/skip/" + skip + "/limit/" + limit,
                    method: 'POST'
                },
                function (err, data) {
                    //判断是否有错误信息
                    if (err) {
                        return cb(err, data);
                    }

                    courseData = data.data;
                    cb();
                }
            );
        },

        function(cb){


            for(var i = 0 ;i<courseData.length;i++){
                var oname = courseData[i].o_name;
                if(resultData[oname]){
                    resultData[oname].push(courseData[i]);
                }else{
                    resultData[oname] = [];
                    resultData[oname].push(courseData[i]);
                }
            }
    
            cb();
        }

        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}